package org.dbwebx.flex.module.bundle.views
{
	import mx.containers.VBox;
	
	import org.dbwebx.domain.Bundle;
	import org.dbwebx.flex.module.bundle.presenter.IBundleManageFormPresenter;
	import org.fxcontainer.controls.ext.Form;
	import org.swizframework.Swiz;

	public class BundleManageFormBase extends VBox
	{
		public function BundleManageFormBase()
		{
			super();
		}

		public var bundleForm:Form;

		[Bindable]
		[Autowire]
		public var model:IBundleManageFormPresenter;


		[Bindable]
		/**
		 * Reference to Bundle.
		 * @default an empty Bundle
		 */
		protected var bundle:Bundle=new Bundle();

		/**
		 * Perform persisting Bundle
		 */
		protected function persistBundle():void
		{
			var gatheredBundle:Bundle=Bundle(bundleForm.submit());
			if (null != gatheredBundle)
			{
				//gatheredBundle.modifier=user;
				model.persistBundle(gatheredBundle);
			}
		}

		/**
		 * Preload data for view
		 * @param event
		 */
		protected function loadModelData(event:Event):void
		{
			//perform model data loading
			Swiz.dispatch("bundleFormModelLoad");
		}
	}
}